'use strict';
const ASE= require('ase')
exports.main = async (event, context) => {
	const db = uniCloud.databaseForJQL({
			event,
			context 
		});
		if(event.id==null||event.id==''){
			return {msg:"访问失败"}
		}
		db.setUser({
			role: ['admin']
		})
	const info=await db.collection("item").where({_id:event.id}).get();
	if(event.type=='ip'){
		await db.collection("item").where({_id:event.id}).update({ip:++info.data[0].ip});
		return {msg:"计算成功"}
	}else if((event.type=='down')){
		await db.collection("item").where({_id:event.id}).update({down:++info.data[0].down});
		return {msg:"计算成功",code:true}
	}
};
